//src/api/user/index.js
import axios from "axios";
import service from "./request.js";

// 使用工号/手机号和密码登录
export function login(query) {
  return service({
    method: "POST",
    url: "/admin-api/system/auth/login",
    data: query,
  });
}
// 刷新令牌
export function refreshToken(query) {
  return service({
    method: "POST",
    url:
      "/admin-api/system/auth/refresh-token?refreshToken=" + query.refreshToken,
    data: query,
  });
}
// 获取登录用户的权限信息
export function getUserInfo() {
  return service({
    method: "GET",
    url: "/admin-api/system/auth/get-permission-info",
  });
}
// 登出系统
export function logout(query) {
  return service({
    method: "POST",
    url: "/admin-api/system/auth/logout",
    data: query,
  });
}
// 获得全部字典数据列表
export function dictList(query) {
  return service({
    method: "GET",
    url: "/admin-api/system/dict-data/list-all",
    data: query,
  });
}

// 获得全部字典数据列表
export function selectData(url, query) {
  return service({
    method: "GET",
    url: url,
    data: query,
  });
}
// 下载文件
export function downloadFn(url, query, other = {}) {
  return service({
    method: "POST",
    url: import.meta.env.VITE_APP_BASE_API + url,
    data: query,
    // headers: {
    //   Authorization: sessionStorage.getItem("token"),
    // },
    responseType: "blob", // 必须更改responseType类型为 blob
    ...other,
  });
}
